<!DOCTYPE html>
<html>
  <head>
    <style>
      body {
        font-family: Tahoma, Geneva, sans-serif;
      }
      div {
        display: inline;
      }
    </style>
    <script>
      var key = 'YOUR KEY',
          secret = 'YOUR SECRET',
          count = 0;
      var host = window.document.location.host.replace(/:.*/, '');
      var ws = new WebSocket('ws://stream.tradingeconomics.com/?client='+key+':'+secret);




      ws.onmessage = function (event) {
        //console.log('Msg: ', event.data);
        count++;
        if(count>=5){ document.getElementById('data_cnt').innerHTML = ''; count=0; }

        var div = document.createElement('div');
            div.innerHTML = event.data;
        document.getElementById('data_cnt').appendChild(div);
        
      };




      ws.onopen = function () {
        console.log('Socket is Open!');
        //subscripe to a topic:
        var topic = 'calendar';
        ws.send('{"topic": "subscribe", "to": "'+topic+'"}');
        ws.send('{"topic": "subscribe", "to": "EURUSD"}');
      };



    </script>
    
  </head>
  <body>
   

    <h3>Data From Socket:</h3>

    <div id="data_cnt">


    </div>

  </body>
</html>